<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>基本资料</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">


    {include file="public_s/style" /}

    {include file="public_s/script" /}
    <style>
        .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-form layuimini-form">
            <div class="layui-form-item">
                <label class="layui-form-label required">管理账号</label>
                <div class="layui-input-block">
                    <input type="text" name="username" lay-verify="required" lay-reqtext="管理账号不能为空" placeholder="请输入管理账号"  value="{$data->username}" class="layui-input">
                    <tip>填写自己管理账号的名称。</tip>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">姓别</label>
                <div class="layui-input-block">
                    <input type="text" name="sex" lay-verify="required" maxlength="1"  lay-reqtext="性别不能为空" placeholder="请输入性别"  value="{$data->sex ? $data->sex : '' }" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">地址</label>
                <div class="layui-input-block">
                    <input type="text" name="address"  placeholder="请输入地址"  value="{$data->address ? $data->address : '' }" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注信息</label>
                <div class="layui-input-block">
                    <textarea name="remark" class="layui-textarea" placeholder="请输入备注信息"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form','miniTab','jquery'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery,
            miniTab = layui.miniTab;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            // var index = layer.alert(JSON.stringify(data.field), {
            //     title: '最终的提交信息'
            // }, function () {
            //     layer.close(index);
            //     miniTab.deleteCurrentByIframe();
            // });
            console.log(data.field)
            if(!data.field['username'] || data.field['username'].length<4){
                layer.msg("帐号名称不能少于4个字符")
                return
            }
            if(!data.field['sex'] || data.field['sex'].length !=1){
                layer.msg("性别不能为空")
                return
            }
            if(!data.field['address'] || data.field['address'].length<4){
                layer.msg("地址不能少于4个字符")
                return
            }

            delete data.field['remark'];

            $.ajax({
                url:'/users/doSubmitDetail',
                method:'post',
                data:data.field,
                success:function(res){
                    layer.msg(res.msg);
                }
            })

            return false;
        });

    });
</script>
</body>
</html>